package com.example.spring_seatreservation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.spring_seatreservation.entity.Announcement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AnnouncementMapper extends BaseMapper<Announcement> {

    @Select("<script>" +
            "select t.*,l.name as library_name from announcement t " +
            "left join library l on l.id = t.lib_id " +
            "<if test=\"libId != null and libId != ''\">" +
            " and t.lib_id = #{libId}" +
            "</if>" +
            "</script>")
    List<Announcement> getAnnouncement(@Param("libId") Long libId);
}
